using System;
using System.Threading.Tasks;

namespace Sharp.Portal.Mvc.OAuth.WeiBo.Provider
{
	public class WeiBoAuthenticationProvider : IWeiBoAuthenticationProvider
	{
		public Func<WeiBoAuthenticatedContext, Task> OnAuthenticated
		{
			get;
			set;
		}

		public Func<WeiBoReturnEndpointContext, Task> OnReturnEndpoint
		{
			get;
			set;
		}

		public Action<WeiBoApplyRedirectContext> OnApplyRedirect
		{
			get;
			set;
		}

		public WeiBoAuthenticationProvider()
		{
			this.OnAuthenticated = (context => Task.FromResult<object>(null));
			this.OnReturnEndpoint = (context => Task.FromResult<object>(null));
			this.OnApplyRedirect = delegate(WeiBoApplyRedirectContext context)
			{
				context.Response.Redirect(context.RedirectUri);
			};
		}

		public virtual Task Authenticated(WeiBoAuthenticatedContext context)
		{
			return this.OnAuthenticated(context);
		}

		public virtual Task ReturnEndpoint(WeiBoReturnEndpointContext context)
		{
			return this.OnReturnEndpoint(context);
		}

		public virtual void ApplyRedirect(WeiBoApplyRedirectContext context)
		{
			this.OnApplyRedirect(context);
		}
	}
}
